var app = getApp();

Page({
    data: {
      store_id:null,
      score:[],
      page:1,
      pagesize:10,
      typeval:'qg',
      listAllLoad: false,
    },
    onLoad: function(o) {
        wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: wx.getStorageSync("color"),
            animation: {
                duration: 0,
                timingFunc: "easeIn"
            }
        }), this.setData({ store_id: o.store_id}), this.getData();
    },
  getData: function (refresh){
      var a = this, s = refresh ? [] : this.data.score;
      app.util.request({
        url: "entry/wxapp/Storewallet",
        cachetime: "0",
        data: {
          store_id: this.data.store_id,
          type: this.data.typeval,
          page: this.data.page,
          pagesize: this.data.pagesize,
        },
        success: function (t) {
          if (!t.data || t.data.length == 0 || t.data.length < a.data.pagesize) {
            a.setData({ listAllLoad: true })
          }
          s = s.concat(t.data), s = function (t) {
            for (var e = [], a = 0; a < t.length; a++) -1 == e.indexOf(t[a]) && e.push(t[a]);
            return e;
          }(s),
          console.log(s)
          , a.setData({
            score: s
          });
          wx.stopPullDownRefresh();
        }
      })
    },
  secType:function(e){
    this.setData({
      typeval: e.currentTarget.dataset.type,
      page: 1,
      listAllLoad: false,
    })
    this.getData(true);
  },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
      this.setData({
        page: 1,
        listAllLoad: false,
      })
      this.getData(true);
    },
    onReachBottom: function() {
      if (!this.data.listAllLoad) {
        this.setData({
          page: this.data.page + 1
        })
        this.getData()
      }
    },
    onShareAppMessage: function() {}
});